package com.ankiang.treeprint.fragment.home;

import android.content.Context;
import android.view.View;

import com.ankiang.treeprint.R;
import com.ankiang.treeprint.fragment.components.TRSettingsFragment;
import com.ankiang.treeprint.manager.QDDataManager;
import com.ankiang.treeprint.view.TRConfig;
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView;
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;

import butterknife.BindView;

/**
 * 主界面，关于 QMUI Util 部分的展示。
 * Created by Kayo on 2016/11/21.
 */

public class HomeSeekpicController extends HomeController {


    // 配置
    private TRConfig conf;
    TRBanner banner;

    @BindView(R.id.groupListView)
    QMUIGroupListView mGroupListView;

    public HomeSeekpicController(Context context) {
        super(context, R.layout.home_seekpic_layout);

        initRecyclerView();
        initGroupListView();
        banner = new TRBanner();
        banner.initBanner(this);
    }

    @Override
    protected String getTitle() {
        return V(R.string.home_seekpic);
    }

    @Override
    protected ItemAdapter getItemAdapter() {
        return new ItemAdapter(getContext(), QDDataManager.getInstance(getContext()).getSeekpicDescriptions());
    }



    private void initGroupListView() {
        View.OnClickListener onClickAnalysisListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v instanceof QMUICommonListItemView) {
                    showAnalysisPage();
                }
            }
        };


        View.OnClickListener onClickCalculatorListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v instanceof QMUICommonListItemView) {
                    showCalculatorPage();
                }
            }
        };

//
//        QMUICommonListItemView itemAnalysis = mGroupListView.createItemView(V(R.string.explore_analysis));
//        itemAnalysis.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
//
//        QMUICommonListItemView itemCalculator = mGroupListView.createItemView(V(R.string.explore_calculator));
//        itemCalculator.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
//
//
//        QMUIGroupListView.newSection(getContext())
//                .addItemView(itemAnalysis, onClickAnalysisListener)
//                .addItemView(itemCalculator, onClickCalculatorListener)
//                .addTo(mGroupListView);
    }


    /**
     * 显示数据分析页面
     */
    private void showAnalysisPage() {
        // todo
        TRSettingsFragment fragment = new TRSettingsFragment();
        startFragment(fragment);
    }


    /**
     * 显示关系计算器页面
     */
    private void showCalculatorPage() {
        // todo
        TRSettingsFragment fragment = new TRSettingsFragment();
        startFragment(fragment);
    }

}


